qinglan.Canvas.ParBulletHelper = qinglan.Canvas.BulletHelper.extend(function(id, opt, map) {

	this.data = qinglan.Canvas.TweenData.createData();

	this.init();

}).methods({
	init: function() {

	},
	initData: function() {
		var data = qinglan.Canvas.BulletHelper.calculate(this.from, this.map, this.opt.type);
		qinglan.Extend.simple(this.data, data, 1);
		this.opt.duration -= this.data.nowTime; //为了实现暂停和恢复
		0 != this.opt.delay && (this.data.isDelay = true);
		this.data.init = true;
	},
	push: function() {
		if (this.supr()) {

		}
	},
	resume: function() {
		if (this.supr()) {
			this.initData();
		}
	},
	setSprite: function(sprite) {
		this.supr(sprite);
		!sprite.data.startTime && (sprite.data.startTime = (new Date()).getTime());
		!sprite.data.nowTime && (sprite.data.nowTime = 0);
		//this.opt.duration -= sprite.data.nowTime; //为了实现暂停和恢复
		this.data.startTime = sprite.data.startTime;
	},
	setMap: function(from, map) {
		var exMap = function(map) {
				var temp = qinglan.Extend.simple({
					theta: 0,
					distance: 0
				}, map, 1);
				//temp.theta = qinglan.Canvas.Const.deg2rad(temp.theta);
				return temp;
			};
		this.map = exMap(map);
		this.from = exMap(from);
		this.data.init = false;
		this.data.isplay = true;
	},
	update: function(ctx) {
		if (this.data.ispaused || !this.data.isplay || this.sprite.data.isStop) { return false;}
		!this.data.init && this.initData();
		if (this.data.isDelay && this.sprite.data.isDelay){
			var dt = (new Date()).getTime();
			var sub = dt - this.sprite.data.startTime; //- this.sprite.data.delay;
			if(sub < this.sprite.data.delay){
				//qinglan.Debug.info('x: ' + this.sprite.position.x + ' y : ' + this.sprite.position.y + 'visible :' + this.sprite.visible);
				return false;
			}else{
				this.sprite.visible = true;
				this.sprite.data.isDelay = false;
				this.sprite.data.startTime = this.data.startTime = (new Date()).getTime();
				this.change(ctx);
			}
		}else{
			this.change(ctx);
		}
		//qinglan.Debug.info('x: ' + this.sprite.position.x + ' y : ' + this.sprite.position.y);
	},
	change: function(ctx){
		qinglan.Canvas.Animate.change(this.sprite, this.data, this.opt, this.stop, this);
		this.sprite.data.nowTime = this.data.nowTime;
		//qinglan.Debug.info(this.data.nowTime);	
	},
	stop: function(){
		this.destory();
		this.sprite.data.isStop = true;
	},
	destory: function() {
		this.sprite.destory();
	}
});
